package com.sservice.service.service.impl;

import com.sservice.model.dao.ISalePersonAccountDao;
import com.sservice.model.entity.SalePersonAccount;
import com.sservice.model.vo.SalePersonAccountVo;
import com.sservice.service.service.ISalePersonAccountService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SalePersonAccountServiceImpl implements ISalePersonAccountService {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private ISalePersonAccountDao dao;

    @Override
    public List<SalePersonAccountVo> queryByPage(SalePersonAccountVo spav) {
        return dao.queryByPage(spav);
    }

    @Override
    public Integer queryCountByPage(SalePersonAccountVo spav) {
        return dao.queryCountByPage(spav);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return dao.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(SalePersonAccount arg) {
        return dao.insert(arg);
    }

    @Override
    public int insertSelective(SalePersonAccount arg) {
        return dao.insertSelective(arg);
    }

    @Override
    public SalePersonAccount selectByPrimaryKey(Integer id) {
        return dao.selectByPrimaryKey(id);
    }

    @Override
    public SalePersonAccount selectBySaleId(String saleId) {
        SalePersonAccount res = dao.selectBySaleID(saleId);
        SalePersonAccount spa = new SalePersonAccount();
        if (res == null) {
            spa.setSaleId(saleId);
            dao.insertSelective(spa);
            res = dao.selectBySaleID(saleId);
        }
        return res;
    }

    @Override
    public int updateByPrimaryKeySelective(SalePersonAccount arg) {
        return dao.updateByPrimaryKeySelective(arg);
    }
}
